/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package gestInt.modelo;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author elkin
 */
@Entity
@Table(name = "administrativo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Administrativo.findAll", query = "SELECT a FROM Administrativo a"),
    @NamedQuery(name = "Administrativo.findByIdAdministrativo", query = "SELECT a FROM Administrativo a WHERE a.administrativoPK.idAdministrativo = :idAdministrativo"),
    @NamedQuery(name = "Administrativo.findByCargo", query = "SELECT a FROM Administrativo a WHERE a.cargo = :cargo"),
    @NamedQuery(name = "Administrativo.findByIdpersona", query = "SELECT a FROM Administrativo a WHERE a.administrativoPK.idpersona = :idpersona"),
    @NamedQuery(name = "Administrativo.findByFacultad", query = "SELECT a FROM Administrativo a WHERE a.facultad = :facultad")})
public class Administrativo implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AdministrativoPK administrativoPK;
    @Size(max = 45)
    @Column(name = "cargo")
    private String cargo;
    @Size(max = 45)
    @Column(name = "facultad")
    private String facultad;
    @JoinColumn(name = "idpersona", referencedColumnName = "idpersona", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Persona persona;

    public Administrativo() {
    }

    public Administrativo(AdministrativoPK administrativoPK) {
        this.administrativoPK = administrativoPK;
    }

    public Administrativo(int idAdministrativo, int idpersona) {
        this.administrativoPK = new AdministrativoPK(idAdministrativo, idpersona);
    }

    public AdministrativoPK getAdministrativoPK() {
        return administrativoPK;
    }

    public void setAdministrativoPK(AdministrativoPK administrativoPK) {
        this.administrativoPK = administrativoPK;
    }

    public String getCargo() {
        return cargo;
    }

    public void setCargo(String cargo) {
        this.cargo = cargo;
    }

    public String getFacultad() {
        return facultad;
    }

    public void setFacultad(String facultad) {
        this.facultad = facultad;
    }

    public Persona getPersona() {
        return persona;
    }

    public void setPersona(Persona persona) {
        this.persona = persona;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (administrativoPK != null ? administrativoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Administrativo)) {
            return false;
        }
        Administrativo other = (Administrativo) object;
        if ((this.administrativoPK == null && other.administrativoPK != null) || (this.administrativoPK != null && !this.administrativoPK.equals(other.administrativoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gestInt.modelo.Administrativo[ administrativoPK=" + administrativoPK + " ]";
    }
    
}
